import axios, { Axios } from 'axios'
const context = '/recipeservice'

/**
 * 获取 materialConfig 分页列表
 */
export function getMaterialConfigPagination(data: any) {
  return axios.get(`${context}/materialConfig/pagination`, { params: data })
}

/**
 * 获取 materialConfig 所有数据
 */
export function getMaterialConfigAllList(data: any) {
  return axios.get(`${context}/materialConfig/all`, { params: data })
}

/**
 * 获取 materialConfig 详情
 */
export function getMaterialConfigDetailById(id: any) {
  return axios.get(`${context}/materialConfig/${id}`, { params: { id } })
}

/**
 * 新增 materialConfig
 */
export function addMaterialConfig(data: any) {
  return axios.post(`${context}/materialConfig`, data)
}

/**
 * 修改 materialConfig
 */
export function updateMaterialConfig(data: any) {
  return axios.put(`${context}/materialConfig`, data)
}

/**
 * 删除 materialConfig
 */
export function batchRemoveMaterialConfig(data: any) {
  return axios.post(`${context}/materialConfig/batchRemove`, data)
}

/***
 * 上传 material config excel 文件
 */
export function batchImportMaterialConfig(data: any) {
  return axios.post(`${context}/materialConfig/import/excel`, data)
}

/***
 * 下载 material config excel 模板
 */
export function downloadMaterialConfig() {
  return axios.get(`${context}/materialConfig/export/excel`, {
    responseType: 'blob', // 关键：接收二进制流
  })
}
